from drg_group.yinchuan_2023.Base import message,intersect,SS_VALID
from drg_group.yinchuan_2023.DRG import MDCN_DRG

def group(record):
  adrg_zd=["A18.100x032","A18.115+N74.1*","C51.900","C52.x00","C53.900","C54.100","C56.x00","C56.x00x003","C57.000","C57.801","D06.900","D06.900x002","D25.000","D25.100x001","D25.200","D25.200x002","D25.900","D25.900x001","D25.901","D26.100x002","D27.x00","D28.202","D39.100x003","D39.101","N70.103","N70.900x003","N70.900x007","N70.902","N70.903","N70.904","N70.905","N73.600","N73.602","N73.603","N73.801","N73.902","N73.903","N80.001","N80.100","N80.100x001","N80.301","N80.302","N80.303","N80.900","N81.101","N81.802","N83.100x002","N83.101","N83.102","N83.201","N83.204","N83.800x017","N83.801","N83.803","N83.809","N83.811","N83.812","N85.101","N85.807","N87.001","N88.300","N94.802","N94.806","N94.807","N94.808","N97.100x003","N97.101","N97.902","N98.100","N99.800x010","Q50.302","Q50.503","Q51.900","T83.303","Z31.000x001"]
  adrg_zd1=[]
  adrg_ss=["38.7x04","40.2400","40.2905","40.2909","40.5910","40.5912","54.0x00x004","54.0x00x010","54.0x01","54.1100","54.1101","54.1900x010","54.1903","54.2100","54.2300x005","54.4x00x007","54.4x00x021","54.4x00x035","54.4x01","54.4x02","54.4x10","54.4x15","54.5100x005","54.5100x009","54.5101","54.5103","54.5903","54.5904","54.7200x001","54.9100x002","54.9100x009","54.9101","54.9900x010","54.9900x011","54.9900x017","69.1900x022","69.1903","69.1904","69.1905","69.1907","69.9100x002","70.3201"]
  adrg_ss1=[]
  adrg_ss2=[]
  dept_list=[]
  if True and record.zdList[0] in adrg_zd and record.ssList and record.ssList[0] in adrg_ss and record.ssList and intersect(record.ssList,adrg_ss):
    message('符合NJ1入组条件，匹配规则：主诊断匹配、主手术匹配、某一手术匹配')
    
    if MDCN_DRG.NJ19_group(record):
      return 'NJ19'

    return 'NJ1'
  else:
    return ''

